package com.example.mapper;

import com.example.pojo.BookMenu;
import org.apache.ibatis.annotations.*;

import java.util.Collection;
import java.util.List;

@Mapper
public interface BookMenuMapper {

    @Select("select * from t_book_menu where id=#{id}")
    @ResultMap("BookMenuResult")
    BookMenu selectById(int id);

    @Select("select * from t_book_menu where isbn=#{isbn}")
    @ResultMap("BookMenuResult")
    List<BookMenu> selectByIsbn(String isbn);

    List<BookMenu> selectByIsbnAndPriceRange(@Param("isbn") String isbn,@Param("price") Double price);

    @Select("select * from t_book_menu where publisher like concat(#{publisherPrefix},'%') order by isbn")
    @ResultMap("BookMenuResult")
    List<BookMenu> selectByPublisherPrefix(String publisherPrefix);

    List<BookMenu> selectByAuthorIdsAndPublisherPrefix(@Param("authorIdList") List<Long> authorIdList,@Param("publisherPrefix") String publisherPrefix);

    @Select("select * from t_book_menu where publish_time like concat(#{publishTimePrefix},'%') order by price")
    @ResultMap("BookMenuResult")
    List<BookMenu> selectByPublishTimePrefix(String publishTimePrefix);

    @Select("select * from t_book_menu where isbn like concat(#{isbnPrefix},'%')")
    @ResultMap("BookMenuResult")
    List<BookMenu> selectByIsbnPrefix(String isbnPrefix);

    int insert(BookMenu bookMenu);

    int update(BookMenu bookMenu);

    int batchUpdate(@Param("collection") Collection<BookMenu> bookMenuList);

}
